Read in the posterior draws of MCMC

library(faraway)
library(tidyverse)
library(plotly)
library(magrittr)
posterior <- read_csv("../Example-Solution/posterior_summary/thinned_MCMC.csv") # x1 is the row name

Which variables are zero more often than others?

key non_zero_freq
Ind[1] 0.0156
Ind[2] 0.0176
Ind[3] 0.0076
Ind[4] 0.0086
Ind[5] 0.1294
Ind[6] 0.0148
Ind[7] 0.0060
Ind[8] 0.0584
Ind[9] 0.1520
Ind[10] 0.4968
Ind[11] 0.0162
Ind[12] 1.0000
Ind[13] 1.0000
Ind[14] 0.0164
Ind[15] 0.1222
Ind[16] 0.0092
Ind[17] 0.0158
Ind[18] 0.0234
Ind[19] 1.0000
Ind[20] 0.3668

We wish to set a visualisation up for three variables that indicate the relationship between these variables when they are non-zero and when they are zero. In this case, we have eight particularly states for whether each variable is zero or not. We draw inspiration from the chmod permission sytem.

expand.grid(x1 =c(0,1), x2=c(0,1), x3=c(0,1)) %>%
  rowwise %>%
  mutate(Group = sum(c(x1, x2, x3) * c(4,2,1))) %>%
  arrange(Group) %>%
  kable
x1 x2 x3 Group
0 0 0 0
0 0 1 1
0 1 0 2
0 1 1 3
1 0 0 4
1 0 1 5
1 1 0 6
1 1 1 7

Applying this, we allocate each MCMC draw for our three parameters, \(\beta_5, \beta_9, \beta_{15}\), to one of these groups and label them with human friendly names that relate to their geometry. We consider parameter draws for which none of the parameters are zero as the dinner roll – a fully 3D ellipsoid which is the first group of interest. When one of the three variables are zero, this projects the draws which are non-zero on to one of the axes planes that define the space. These are labelled as pita bread, a flat and misshapen collection of MCMC draws. Notably, the pita are not the shadow of the dinner roll. When two parameters are zero, the points are projected onto one of three orthogonal axes, and stick out from the origin like grissini in a cup. This is where the opacity is most important, as no one wants grissini that have been overplotted. When all three parameters are zero, the parameter draws collapse to a donut hole placed at the origin.

Interact with this plotly plot by rotating the axes in 3D space. You can single click a classification to turn it off, or double click one to turn all others off.